package cw.itsource.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/ribbon")
public class RibbonController {

    @Autowired
    private RestTemplate restTemplate;

    //定义所要消费的服务名称，该名称需要和我们注册中里面服务注册的名称保持一致
    private static String serverName = "USER-PROVIDER";

    @GetMapping
    public String getProvider(){
        //通过服务名去调用消息提供者的服务
        String url ="http://" + serverName +"/provider";
        return restTemplate.getForObject(url,String.class);
    }


}
